package com.xzs.user.controller;

import com.xzs.core.Result;
import com.xzs.core.ResultGenerator;
import com.xzs.entity.Admin;
import com.xzs.user.service.AdminService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;
import com.xzs.core.ResultList;
import javax.annotation.Resource;
import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;

/**
* Created by xzs on 2018/01/15.
*/
@RestController
//@RequestMapping("/admin")
@Api(value = "Admin",description = "管理员表")
public class AdminController {
    @Autowired
    private AdminService adminService;

	@ApiOperation(value = "获取全部管理员表")
    @GetMapping("/admins")
    public Result<ResultList<Admin>> list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
        PageHelper.startPage(page, size);
        List<Admin> list = adminService.findAll();
        PageInfo pageInfo = new PageInfo(list);
        return ResultGenerator.genSuccessResult(ResultList.genResultList(pageInfo));
        //throw new UnsupportedOperationException();
    }
}
